package ink.teamwork.battery.model;

public class Result {

    public int code;

    public String msg;

    public Object data;

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result of(Integer code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    public static Result success() {
        return new Result(0, "SUCCESS", null);
    }

    public static Result success(Object data) {
        return new Result(0, "SUCCESS", data);
    }

    public static Result warn(String msg) {
        return new Result(2, msg, null);
    }

    public static Result fail(String msg) {
        return new Result(1, msg, null);
    }

    public static Result error(String msg) {
        return new Result(-1, msg, null);
    }

}
